package Source;

import java.util.ArrayList;

/**
 * The create flight model
 * @author Joshua King
 */
public class CreateFlight {
    private String flightDepartureLoc ="";
    private String flightArrivalLoc="";
    private String  flightDepartureDate="";
    private String  flightArrivalDate="";
    private String  flightDepartureTime="";
    private String  flightArrivalTime="";
    private String  flightNoSeat="";
/**
 * checks to see if the data is valid
 */
    public boolean checkValidity() {
        if (flightDepartureLoc.equals("") || flightArrivalLoc.equals("") || 
                flightDepartureDate.equals("") || flightArrivalDate.equals("") || 
                flightDepartureTime.equals("") || flightArrivalTime.equals("") ||
                        flightNoSeat.equals("")) {
            return false;
        }
        return true;
    }
/**
 * writes to the database
 */
    public boolean commitData() {
        FlightServerInteraction logIn = new FlightServerInteraction();
        ArrayList<String> request = new ArrayList<String>();
        ArrayList<String> reply = new ArrayList<String>();
        request.add(0,"flightCreate");
        request.add(1,flightDepartureLoc);
        request.add(2,flightArrivalLoc);
        request.add(3,flightDepartureDate);
        request.add(4,flightArrivalDate);
        request.add(5,flightDepartureTime);
        request.add(6,flightArrivalTime);
        request.add(7,flightNoSeat);
        request.add(8,"100.00");
        reply = logIn.run(request);
        return true;
    }
/**
 * sets the flight date
 * @parm flightArrivalDate the date
 */
    public void setFlightArrivalDate(String flightArrivalDate) {
        this.flightArrivalDate = flightArrivalDate;
    }
/**
 * sets the flight arrival location
 * @parm flightArrivalLoc the arrival location
 */
    public void setFlightArrivalLoc(String flightArrivalLoc) {
        this.flightArrivalLoc = flightArrivalLoc;
    }
/**
 * sets the flight arrival time
 * @param flightArrivalTime the time of arrival
 */
    public void setFlightArrivalTime(String flightArrivalTime) {
        this.flightArrivalTime = flightArrivalTime;
    }
/**
 * sets the flight date
 * @parm flightArrivalDate the date
 */
    public void setFlightDepartureDate(String flightDepartureDate) {
        this.flightDepartureDate = flightDepartureDate;
    }
/**
 * sets the flight departure location
 * @parm flightDepartureLoc the departure location
 */
    public void setFlightDepartureLoc(String flightDepartureLoc) {
        this.flightDepartureLoc = flightDepartureLoc;
    }
/**
 * sets the flight departure time
 * @parm flightDepartureTime the departure time
 */
    public void setFlightDepartureTime(String flightDepartureTime) {
        this.flightDepartureTime = flightDepartureTime;
    }
/**
 * sets the flight seat number
 * @parm flightNoSeat the number of seats
 */
    public void setFlightNoSeat(String flightNoSeat) {
        this.flightNoSeat = flightNoSeat;
    }

}
